id  = 0
sda = 3
scl = 4
dev_addr=0x3c
i2c.setup(id, sda, scl, i2c.SLOW)
i2c.start(id)
i2c.address(id, dev_addr, i2c.TRANSMITTER)
disp = u8g.ssd1306_128x64_i2c(dev_addr)
disp:setFont(u8g.font_6x10)
local s = 0
function draw(state)
    if state == 0 then 
        disp:drawStr(0, 15, "drawBox")
        disp:drawBox(0, 23, 10, 20)
    elseif state == 1 then
        disp:drawStr(0, 15, "drawCircle")
        disp:drawCircle(36, 36, 10)
    elseif state == 2 then
        disp:drawStr(0, 15, "drawDisc")
        disp:drawDisc(36, 36, 15)
    elseif state == 3 then
        disp:drawStr(0, 15, "drawEllipse")
        disp:drawEllipse(60, 30, 20, 10, U8G_DRAW_ALL)
    elseif state == 4 then
        disp:drawStr(0, 15, "drawFrame")
        disp:drawFrame(60, 20, 20, 30)   
    elseif state == 5 then
        disp:drawStr(0, 15, "drawLine")
        disp:drawLine(5,26, 25, 40)
    elseif state == 6 then
        disp:drawStr(0, 15, "drawStr")
        disp:drawStr90(60, 20, "drawStr90") 
    else  
        disp:drawStr(0, 15, "drawTriangle")
        disp:drawTriangle(14,20, 45,32, 9,42);    
    end
end
disp:begin()
tmr.alarm(0, 1000, tmr.ALARM_AUTO, function()
    if s == 7 then
        s = 0
    else 
        s = s + 1
    end
    disp:firstPage()
    while (disp:nextPage())
    do 
        draw(s)
    end
end)